package com.woniuxy.service.impl;


import com.woniuxy.dao.UserDao;
import com.woniuxy.entity.LoginUserDetail;
import com.woniuxy.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserDetailServiceImpl implements UserDetailsService {
    @Autowired
    UserDao userDao;
    @Override
    public UserDetails loadUserByUsername(String account) throws UsernameNotFoundException {
        User findUser=userDao.selectByAccount(account);



        if (findUser==null){

            throw new RuntimeException("用户不存在") ;

        }




        return new LoginUserDetail(findUser);
    }
}
